<?php
declare (strict_types=1);

namespace app\admin\controller\user;

use think\response\Json;
use app\admin\controller\Controller;
use app\admin\model\user\Feedback as FeedbackModel;
/**
 * 投诉建议
 * Class Feedback
 * @package app\admin\controller\user
 */
class Feedback extends Controller
{
    /**
     * 投诉建议
     * @return Json
     */
    public function log(): Json
    {
        $model = new FeedbackModel;
        $list = $model->getList($this->request->param())->toArray();
        return $this->renderSuccess([
            'total' => $list['total'],
            'items' => $list['data']
        ]);
    }
    /**
     * 删除
     * @param int $id
     * @return Json
     */
    public function delete(int $id): Json
    {
        $model = FeedbackModel::detail($id);
        if (!$model->delete()) {
            return $this->renderError($model->getError() ?: '删除失败');
        }
        return $this->renderSuccess('删除成功');
    }
}
